// 字符串去重 
function uniq(arr1:string){
    let arr2:string[]=[];
    (arr1.split('')).forEach(item=>{
        if(arr2.indexOf(item)==-1){
            arr2.push(item)
        }
    })
    return (arr2.join(''))
}
console.log(uniq('122222222222'));





// 实现冒泡排序：

function Sort(arr:number[]) {
    for (let i = 0; i < arr.length - 1; i++) {
        for (let j = 0; j < arr.length - 1 - i; j++) {
            if (arr[j] > arr[j + 1]) {
                let temp = arr[j]
                arr[j] = arr[j + 1]
                arr[j + 1] = temp
            }
        }
    }
    return arr
}
    let arr1:number[]=[6,5,4,3,2,1]

    console.log(Sort(arr1));
    

    
// // 数组去重求和
// console.log('2222');

function getSum(arr:any[]):number{
    let num:number=0;
    let newArr:number[]=[];
    for(let i=0;i<arr.length;i++){
        if(typeof(arr[i])=='number'){
            if(newArr.indexOf(arr[i])==-1){
                newArr.push(arr[i])
            }
        }
    }
    for(let j=0;j<newArr.length;j++){
        num+=newArr[j]
    }
    return num
}
console.log(getSum([undefined,"23year",19,"097",1,"hello",null,1]));


